<template>
    <view  v-for="item in data" :key="item._id" v-show="item.class_id[0].user_id.includes(userInfo._id) && item.create_homework_time.includes(single)" >
			<!-- 通过header插槽定义列表顶部显示为图片 -->
			<uni-card>
					<view class="">
						<uni-dateformat :date="item.create_homework_time"></uni-dateformat>
					</view>
					<view class="uni-title">作业标题:{{item.homework_title}}</view>
					<view class="uni-title" >作业详情:{{item.homework_detail}}</view>
					<view class="" v-for="img in item.homework_image" :key="img.path">
						<cover-image :src="img.url" @tap="previewImage(img.url)"></cover-image>
					</view>	
			</uni-card>
	</view>

</template>

<script>

export default {
    name: 'HomeworkCard',
    // 接收父组件的数据
    props: {
        data: {
            type: Array,
            default: []
        },
        single: {
            type: String,
            default: ''
        },
        userInfo: {
            type: Object,
            default: {}
        }
    },
    onShow(){
        // 打印props里面的数据
        console.log("card中的this.data",this.data)
    },
    // data() {
    //     return {
    //         // 当前作业id
    //         homework_id: '',
    //     }
    // },
    methods: {
        previewImage(url) {
            uni.previewImage({
                current: url,
                urls: [url]
            })
        }
    }
}
</script>

<style scoped>

</style>


